Full source code website bán hàng thương mại điện tử gần giống shopee
468.816 lượt xem;
1 <?
2 if (isset($_POST['butSaveLoai'])) {
3 $donvi = trim($_POST['txtName']);
4 $parent = $_POST['txtParent'];
5
6 if ($donvi=="")
7 {
8 echo "<p align=center class='err'>Bạn chưa nhập tên đơn vị</p>";
9 }
10 else
11 {
12 if (!empty($_POST['oldid'])) {
13 $oldid = $_POST['oldid'];
14 $sql = "update donvi set dv_name='".$donvi."',parent_id='".$parent."' where dv_id='".$oldid."'";
15 }
16 else
17 $sql = "insert into donvi (dv_name,parent_id) values ('".$donvi."','".$parent."')";
18 if (mysql_query($sql,$con)) {
19 echo "<p align=center class='err'>Đã cập nhật thành công</p><br>";
20 echo "<script>window.location='index.php?act=donvi_id&page=".$_REQUEST['page']."'</script>";
21 }
22 else echo "<p align=center class='err'>Không thể cập nhật</p>";
23 }
24 }
25 ?>
26
27 <?
28 if (isset($_GET['id'])) {
29 $oldid=$_GET['id'];
30 $sql = "select * from donvi where dv_id='".$oldid."'";
31 if ($result = mysql_query($sql,$con)) {
32 $row=mysql_fetch_array($result);
33 $donvi=$row['dv_name'];
34 $parent=$row['parent_id'];
35 }
36 }
37 ?>
38
39 <form method="POST" name="FormLoaiSP" action="index.php">
40 <input type=hidden name="act" value="donvi_id_m">
41 <input type=hidden name="oldid" value="<? echo $oldid; ?>">
42 <input type=hidden name="page" value="<? echo $_REQUEST['page']; ?>">
43 <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#0069A8" width="100%" id="AutoNumber1">
44 <tr>
45 <td width="45%" align="center" class="title" height="20">Thêm mới / Cập nhật :
46 Đơn vị</td>
47 </tr>
48 <tr>
49 <td width="45%">
50 <table border="0" cellpadding="4" bordercolor="#111111" width="100%" id="AutoNumber2" cellspacing="0">
51 <tr>
52 <td width="15%" class="smallfont">
53 <p align="right">Đơn vị</td>
54 <td width="1%" class="smallfont">
55 <font color="#FF0000">*</font></td>
56 <td width="83%" class="smallfont">
57 <INPUT value="<? echo $donvi; ?>" TYPE="text" NAME="txtName" CLASS=textbox size="34"></td>
58 </tr>
59 <tr>
60 <td width="15%" class="smallfont">
61 <p align="right">Thuộc danh mục</td>
62 <td width="1%" class="smallfont">
63 </td>
64 <td width="83%" class="smallfont">
65 <select size="1" name="txtParent">
66 <?
67 //echo "<option value='0'>[Danh mục gốc]</option>";
68 $cats=GetListDonvi("","=");
69 foreach ($cats as $cat)
70 {
71 if ($cat[0]==$parent)
72 echo "<option value=".$cat[0]." selected>".$cat[1]."</option>";
73 else
74 echo "<option value=".$cat[0].">".$cat[1]."</option>";
75 }
76 ?>
77 </select>
78
79 </td>
80 </tr>
81
82 <tr>
83 <td width="15%" class="smallfont">
84 <p align="right">
85 <INPUT TYPE="submit" NAME="butSaveLoai" VALUE="Cập nhật" CLASS=button> </td>
86 <td width="1%" class="smallfont">
87 </td>
88 <td width="83%" class="smallfont"><p align="left"> <INPUT TYPE="reset" CLASS=button value="Nhập lại"></td>
89 </tr>
90 </table>
91 </td>
92 </tr>
93 </table>
94 </form>
2 if (isset($_POST['butSaveLoai'])) {
3 $donvi = trim($_POST['txtName']);
4 $parent = $_POST['txtParent'];
5
6 if ($donvi=="")
7 {
8 echo "<p align=center class='err'>Bạn chưa nhập tên đơn vị</p>";
9 }
10 else
11 {
12 if (!empty($_POST['oldid'])) {
13 $oldid = $_POST['oldid'];
14 $sql = "update donvi set dv_name='".$donvi."',parent_id='".$parent."' where dv_id='".$oldid."'";
15 }
16 else
17 $sql = "insert into donvi (dv_name,parent_id) values ('".$donvi."','".$parent."')";
18 if (mysql_query($sql,$con)) {
19 echo "<p align=center class='err'>Đã cập nhật thành công</p><br>";
20 echo "<script>window.location='index.php?act=donvi_id&page=".$_REQUEST['page']."'</script>";
21 }
22 else echo "<p align=center class='err'>Không thể cập nhật</p>";
23 }
24 }
25 ?>
26
27 <?
28 if (isset($_GET['id'])) {
29 $oldid=$_GET['id'];
30 $sql = "select * from donvi where dv_id='".$oldid."'";
31 if ($result = mysql_query($sql,$con)) {
32 $row=mysql_fetch_array($result);
33 $donvi=$row['dv_name'];
34 $parent=$row['parent_id'];
35 }
36 }
37 ?>
38
39 <form method="POST" name="FormLoaiSP" action="index.php">
40 <input type=hidden name="act" value="donvi_id_m">
41 <input type=hidden name="oldid" value="<? echo $oldid; ?>">
42 <input type=hidden name="page" value="<? echo $_REQUEST['page']; ?>">
43 <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#0069A8" width="100%" id="AutoNumber1">
44 <tr>
45 <td width="45%" align="center" class="title" height="20">Thêm mới / Cập nhật :
46 Đơn vị</td>
47 </tr>
48 <tr>
49 <td width="45%">
50 <table border="0" cellpadding="4" bordercolor="#111111" width="100%" id="AutoNumber2" cellspacing="0">
51 <tr>
52 <td width="15%" class="smallfont">
53 <p align="right">Đơn vị</td>
54 <td width="1%" class="smallfont">
55 <font color="#FF0000">*</font></td>
56 <td width="83%" class="smallfont">
57 <INPUT value="<? echo $donvi; ?>" TYPE="text" NAME="txtName" CLASS=textbox size="34"></td>
58 </tr>
59 <tr>
60 <td width="15%" class="smallfont">
61 <p align="right">Thuộc danh mục</td>
62 <td width="1%" class="smallfont">
63 </td>
64 <td width="83%" class="smallfont">
65 <select size="1" name="txtParent">
66 <?
67 //echo "<option value='0'>[Danh mục gốc]</option>";
68 $cats=GetListDonvi("","=");
69 foreach ($cats as $cat)
70 {
71 if ($cat[0]==$parent)
72 echo "<option value=".$cat[0]." selected>".$cat[1]."</option>";
73 else
74 echo "<option value=".$cat[0].">".$cat[1]."</option>";
75 }
76 ?>
77 </select>
78
79 </td>
80 </tr>
81
82 <tr>
83 <td width="15%" class="smallfont">
84 <p align="right">
85 <INPUT TYPE="submit" NAME="butSaveLoai" VALUE="Cập nhật" CLASS=button> </td>
86 <td width="1%" class="smallfont">
87 </td>
88 <td width="83%" class="smallfont"><p align="left"> <INPUT TYPE="reset" CLASS=button value="Nhập lại"></td>
89 </tr>
90 </table>
91 </td>
92 </tr>
93 </table>
94 </form>